﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace WWWSiteHelper
{
    [Serializable()]
    public class AbstractFile
    {
        public enum FileType { Html5, Css, JavaScript, Php };

        public string Name { get; protected set; }
        public FileType Type { get; protected set; }
        public ProjectId Project { get; set; }

        public AbstractFile(string name, FileType type, ProjectId project)
        {
            Name = name;
            Type = type;
            Project = project;
        }
        public string Load()
        {
            return Project.LoadFile(this);
        }

        public bool Save(string content)
        {
            return Project.SaveFile(this, content);
        }

        public override bool Equals(object obj)
        {
            if (obj is AbstractFile)
            {
                AbstractFile f = (AbstractFile)obj;
                return f.Name == Name && f.Type == Type;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode() + 7 * Type.GetHashCode();
        }

    }
}